package cn.itsource.pethome.order.controller;

import cn.itsource.pethome.basic.util.AjaxResult;
import cn.itsource.pethome.basic.util.UserContext;
import cn.itsource.pethome.order.service.IProductOrderService;
import cn.itsource.pethome.user.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @description: 描述:
 * @date: 2020/8/26 16:13
 * @author: summer
 * version: 1.0
 */
@RestController
@RequestMapping("/productOrder")
public class ProductOrderController {

    @Autowired
    private IProductOrderService productOrderService;

    @PostMapping("/submitOrder")
    public AjaxResult submitOrder(@RequestBody Map<String,Object> partm, HttpServletRequest request){
        try {
            User user = UserContext.getLoginUser(request);
            String form = productOrderService.submitOrder(user, partm);
            return new AjaxResult().setResult(form);
        } catch (Exception e) {
            e.printStackTrace();
            return new AjaxResult(false, e.getMessage());
        }
    }

}
